﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.DataModel;

namespace HYRElectric.Equipment
{
	public class DeleteProtectionRadius
	{
		public DeleteProtectionRadius(Document document)
		{
			this.doc = document;
		}

		public bool DoDelete()
		{
			if (this.doc == null)
			{
				return false;
			}
			Transaction transaction = null;
			bool result;
			try
			{
				transaction = new Transaction(this.doc, "清除保护半径");
				transaction.Start();
				new AuxiliaryLineOperate().DeleteRangLine(this.doc, "FireCheck");
				this.doc.Regenerate();
				transaction.Commit();
				result = true;
			}
			catch (Exception ex)
			{
				if (transaction != null && transaction.GetStatus() != TransactionStatus.Committed)
				{
					transaction.RollBack();
				}
				TaskDialog.Show("盈建科提示", ex.Message);
				result = false;
			}
			return result;
		}

		private Document doc;
	}
}
